matrix World;
matrix Projection;
matrix View;
Texture2D Tex2D;
float4 GlobalColor;

SamplerState LinearSampler
{
    Filter = MIN_MAG_MIP_POINT;
    AddressU = CLAMP;
    AddressV = CLAMP;
};

BlendState SrcAlphaBlendingAdd
{
    BlendEnable[0] = TRUE;
    SrcBlend = SRC_ALPHA;
    DestBlend = INV_SRC_ALPHA;
    BlendOp = ADD;
    SrcBlendAlpha = ZERO;
    DestBlendAlpha = ZERO;
    BlendOpAlpha = ADD;
    RenderTargetWriteMask[0] = 0x0F;
};

struct VSInput
{
	float4 Pos : POSITION;
	float2 Tex : TEXCOORD;
};

struct PSInput
{
	float4 Pos : SV_POSITION;
	float4 Color : COLOR;
	float2 Tex : TEXCOORD;
};

PSInput DefaultVS( VSInput input )
{
	PSInput output;
	//output.Pos = mul( input.Pos, World );
	//output.Pos = mul( output.Pos, View );
	//output.Pos = mul( output.Pos, Projection );
	output.Pos = mul(input.Pos, Projection);
    output.Color = GlobalColor;
	output.Tex = input.Tex;

	return output;
}

float4 TexturedPS( PSInput input ) : SV_Target
{
    return Tex2D.Sample(LinearSampler, input.Tex) * input.Color;
}

float4 UntexturedPS( PSInput input ) : SV_Target
{
	return input.Color;
}

technique10 Full
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, DefaultVS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, TexturedPS() ) );
        SetBlendState( SrcAlphaBlendingAdd, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
    }
}

technique10 NoTex
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, DefaultVS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, UntexturedPS() ) );
        SetBlendState( SrcAlphaBlendingAdd, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
    }
}